var __assign =
  (this && this.__assign) ||
  function () {
    __assign =
      Object.assign ||
      function (t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
          s = arguments[i];
          for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
      };
    return __assign.apply(this, arguments);
  };
import React, { useMemo } from 'react';
import { ConfigProp } from './components/ConfigProp';
import { Divider } from 'antd';
import { ConfigInputProp } from './components/ConfigInputProps';
import { ConfigStyle } from './components/ConfigStyle';
import { ConfigsContext } from '..';
import { useConfigContext } from '../contexts/ConfigContext';
export default function LeggoRight() {
  var contextValue = useConfigContext();
  var activeSchema = contextValue.activeSchema,
    schemaList = contextValue.schemaList;
  var _a = activeSchema.current || {},
    id = _a.id,
    configs = _a.configs;
  var _b = configs || {},
    itemProps = _b.itemProps,
    inputProps = _b.inputProps,
    extra = _b.extra;
  var itemPropsEntries = useMemo(
    function () {
      return Object.entries(itemProps || {});
    },
    [activeSchema.current]
  );
  var inputPropsEntries = useMemo(
    function () {
      return Object.entries(inputProps || {});
    },
    [activeSchema.current]
  );
  var extraEntries = useMemo(
    function () {
      return Object.entries(extra || {});
    },
    [activeSchema.current]
  );
  var newContextValue = useMemo(
    function () {
      var schemaListOptions = [
        {
          label: '公共状态 - publicStates',
          value: 'publicStates'
        }
      ].concat(
        schemaList.map(function (schema) {
          var _a = schema.configs.itemProps,
            label = _a.label,
            name = _a.name;
          return {
            label: ''.concat(label, ' - ').concat(String(name)),
            value: String(name)
          };
        })
      );
      return __assign(__assign({}, contextValue), { schemaListOptions: schemaListOptions });
    },
    [schemaList]
  );
  return React.createElement(
    ConfigsContext.Provider,
    { value: newContextValue },
    React.createElement(
      'div',
      { className: 'leggo-configs-right' },
      React.createElement(
        'div',
        { className: 'top-area' },
        React.createElement('strong', null, '\u5C5E\u6027\u914D\u7F6E')
      ),
      React.createElement(
        'div',
        { className: 'scroll-container' },
        React.createElement(
          'div',
          { className: 'configs-area' },
          React.createElement(Divider, null, 'ItemProps'),
          itemPropsEntries.map(function (_a) {
            var propName = _a[0],
              value = _a[1];
            return React.createElement(ConfigProp, {
              key: id + propName,
              propOwner: itemProps,
              namepath: ['itemProps', propName],
              propName: propName,
              propDefaultValue: value
            });
          })
        ),
        React.createElement(
          'div',
          { className: 'configs-area' },
          React.createElement(Divider, null, 'InputProps'),
          activeSchema.current && React.createElement(ConfigStyle, { key: id }),
          inputPropsEntries.map(function (_a) {
            var propName = _a[0],
              value = _a[1];
            return React.createElement(ConfigInputProp, {
              key: id + propName,
              propOwner: inputProps,
              namepath: ['inputProps', propName],
              propName: propName,
              propDefaultValue: value
            });
          })
        ),
        React.createElement(
          'div',
          { className: 'configs-area' },
          React.createElement(Divider, null, 'Extra'),
          extraEntries.map(function (_a) {
            var propName = _a[0],
              value = _a[1];
            return React.createElement(ConfigProp, {
              key: id + propName,
              propOwner: extra,
              namepath: ['extra', propName],
              propName: propName,
              propDefaultValue: value
            });
          })
        )
      )
    )
  );
}
